import {listRoot,listChildren} from "@/api/certificate/area";

export const AreaMixins = {
  data(){
    return {
      // 省份列表
      mixinsProvinceList: [],
      // 市列表
      mixinsCityList: [],
      // 区县列表
      mixinsAreaList: [],
      //街道列表
      mixinsStreetList:[],
    }
  },
  created() {
    this.initProvinceList()
  },
  methods:{
    //初始化省
    initProvinceList() {
      listRoot().then(res => {
        this.mixinsProvinceList = res.rows;
      })
    },
    //选择省改变1
    mixinsProvinceChange(parentCode) {
      console.log(parentCode)
      listChildren({parentCode:parentCode}).then(res => {
        this.mixinsCityList = res.rows;
      })
    },
    //选择市改变
    mixinsCityChange(parentCode) {
      listChildren({parentCode:parentCode}).then(res => {
        this.mixinsAreaList = res.rows;
      })
    },
    //选择区改变
    mixinsAreaChange(parentCode){
      listChildren({parentCode:parentCode}).then(res => {
        this.mixinsStreetList = res.rows;
      })
    },
    //重置
    mixinsResetAreaList(){
      this.mixinsCityList=[]
      this.mixinsAreaList=[]
      this.mixinsStreetList=[]
    },
  }
}
